﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class CMS_Control_Search : System.Web.UI.UserControl
{

    Usas.BLL.Cms.cmsType ct = new Usas.BLL.Cms.cmsType();
    Usas.Common.Cms.Role ro = new Usas.Common.Cms.Role();
    Usas.BLL.Cms.AspPager ap = new Usas.BLL.Cms.AspPager();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //DataTable dt = null;

            //if (Cache["TypeId"] != null)
            //{
            //    dt = Cache["TypeId"] as DataTable;
            //}
            //else
            //{
            //    dt = ((DataSet)ct.GetList("Del = 0")).Tables[0];
            //    Cache.Insert("TypeId", dt, null, DateTime.Now.AddHours(1), TimeSpan.Zero);
            //}
            //DDL.Items.Add(new ListItem("全部专栏", "-1"));
            //if (dt.Rows.Count > 0)
            //{
            DataTable dt = ap.GetTypeTableBySetting(ro.GetSelfSettingRole() + " and p_type=0", "Del <> 1", 1, -1, "TypeOrder");
            for (int i = dt.Rows.Count-1; i >=0; i--)
            {
                DDL.Items.Add(new ListItem(dt.Rows[i]["TypeName"].ToString(), dt.Rows[i]["TypeId"].ToString()));
            }

            //}


            DDL.SelectedValue = "-1";
        }
    }




    protected void Sbtn_Click(object sender, EventArgs e)
    {
        string yp = DDLType.SelectedValue;
        string id = DDL.SelectedValue;
        string kw = keyword.Value;
        if (kw.Length <= 0)
        {
            Response.Redirect(Request.Url.ToString());
            return;
        }
        Response.Redirect("SearchList.aspx?typeid=" + id + "&mode=" + yp + "&keyword=" + Server.UrlEncode(kw));

    }
}
